package com.day01;

import java.util.Date;

/**
 * @Author liuyuan
 * @Date 2022/11/4 10:07 AM
 * @Version 1.0
 */
public class Dog {
//    Dog是个狗的类名
//    这个类对象 这个类对象就是用来描述狗相貌特征
//    包括一些方法
    int weight;
    String name;
    String color;
    int height;
    Date birthday;
    //方法的形参必须要有数据类型
    void setName(String name){
        //this指的就是这个dog类型.谁 就是谁的属性
        this.name = name;
    }
    //获取名称
    String getName(){
        return this.name;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "weight=" + weight +
                ", name='" + name + '\'' +
                ", color='" + color + '\'' +
                ", height=" + height +
                ", birthday=" + birthday +
                '}';
    }

    //void 是没有返回值
    void say(){
        System.out.println(this.name +":"+"汪汪汪");
    }
    //返回的字符串 void那个地方就要写成返回值类型
     String say1(){
        return "返回的汪汪汪";
    }

    public static void main(String[] args) {
        //1.为什么要有类
        //2.为什么要有属性，和方法

        //创建一个对象
        Dog dog1 = new Dog();
        dog1.setName("大黄");
        dog1.setBirthday(new Date());
        dog1.setColor("yellow");
        dog1.setHeight(50);
        dog1.setWeight(100);
        System.out.println(dog1.toString());
        dog1.say();
        Dog dog2 = new Dog();
        dog2.setName("泰迪");
        dog2.say();

    }
}
